home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Apple Development Tools / MacsBug 6.5.4a6.sit / MacsBug 6.5.4a6 / Building dcmds / Pascal Samples / Where.p < prev    next >
Text File  |  1998-09-22  |  3KB  |  98 lines

  1. {
  2.     File:                            Where.p
  3.  
  4.     Contains:            Pascal source for the Where dcmd
  5.  
  6.     Written by:    JM3 = Jim Murphy
  7.  
  8.     Copyright:        © 1991, 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <2>   14-Dec-94    JM3        Updated for format 3 dcmd requirements.
  13.  
  14. }
  15.  
  16. UNIT Where;
  17.  
  18. (* The following MPW commands will build the dcmd and copy it to the
  19.    "Debugger Prefs" file in the System folder. The dcmd's name in
  20.          MacsBug will be the name of the file built by the Linker.
  21.  
  22.         Pascal Where.p
  23.         Link dcmdGlue.a.o Where.p.o {Libraries}Runtime.o -o Where
  24.         BuildDcmd Where 102
  25.                     Echo 'include "Where";'            |            Rez -a -o "{systemFolder}Debugger Prefs"
  26. *)
  27.  
  28. {$R-}
  29.  
  30. INTERFACE
  31.  
  32.         USES MemTypes, dcmd;
  33.         
  34.   { Public declaration for dcmdGlue. Must be in every dcmd. The name cannot be changed. }
  35.         PROCEDURE CommandEntry (paramPtr: dcmdBlockPtr);
  36.  
  37.  
  38. IMPLEMENTATION
  39.  
  40. CONST CR = $0D;
  41.  
  42.  
  43. PROCEDURE CommandEntry (paramPtr: DCmdBlockPtr);
  44. VAR address: LONGINT;
  45.     ch:      CHAR;
  46.                 ok:      BOOLEAN;
  47.                 name:    Str255;
  48. BEGIN
  49.   IF paramPtr^.request = dcmdInit THEN
  50.           BEGIN { The dcmd gets called once when loaded to init itself }
  51.                 END
  52.         ELSE
  53.   IF paramPtr^.request = dcmdDoIt THEN
  54.           BEGIN { Do the command's normal function }
  55.                 IF dcmdPeekAtNextChar = CHR(CR) THEN
  56.                   address := paramPtr^.registerFile^[PCRegister]
  57.                 ELSE
  58.                   BEGIN
  59.                   ch := dcmdGetNextExpression (address, ok);
  60.                         IF NOT ok THEN
  61.                           BEGIN
  62.                                 dcmdDrawLine ('Syntax error');
  63.                                 Exit (CommandEntry);
  64.                                 END;
  65.                         END;
  66.                 IF (address >= $0000A000) AND (address <= $0000ABFF) THEN
  67.                   BEGIN
  68.                         dcmdGetTrapName (address, name);
  69.                         dcmdDrawLine (name);
  70.                         END
  71.                 ELSE
  72.                   BEGIN
  73.                         dcmdGetNameAndOffset (address, name);
  74.                   IF Length (name) > 0
  75.                           THEN dcmdDrawLine (name)
  76.                                 ELSE dcmdDrawLine ('No procedure name found');
  77.                         END;
  78.                 END
  79.         ELSE
  80.   IF paramPtr^.request = dcmdHelp THEN
  81.           BEGIN { Display the command's help information }
  82.                 dcmdDrawLine ('Display information about the address or trap');
  83.                 dcmdDrawLine ('If no parameter then use PC as the address');
  84.         END ELSE IF paramPtr^.request = dcmdGetInfo THEN BEGIN
  85.             GetInfoRequestBlockPtr(paramPtr^.requestIOBlock)^.usageStr := '[addr | trap]';
  86.             GetInfoRequestBlockPtr(paramPtr^.requestIOBlock)^.creditsStr := '';
  87.     
  88.             { Set the version to 3.0 final. }
  89.     
  90.             GetInfoRequestBlockPtr(paramPtr^.requestIOBlock)^.dcmdVersion.majorRev := $03;
  91.             GetInfoRequestBlockPtr(paramPtr^.requestIOBlock)^.dcmdVersion.minorAndBugRev := $00;
  92.             GetInfoRequestBlockPtr(paramPtr^.requestIOBlock)^.dcmdVersion.stage := $80;
  93.             GetInfoRequestBlockPtr(paramPtr^.requestIOBlock)^.dcmdVersion.nonRelRev := $00;        
  94.         END;
  95. END;
  96.  
  97. END.
  98.